package com.hualude.roadsign.repository;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.RuleGroupDto;
import com.hualude.roadsign.model.RuleGroupEntity;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface RuleGroupRepository extends CrudRepository<RuleGroupEntity, Integer> {

    public List<RuleGroupDto> getRuleGroup4DT(DTRequestDto dtRequestDto, String orgIds, String content, String time) throws Exception;

    public Integer getRuleGroupCount4DT(DTRequestDto dtRequestDto, String orgIds, String content, String time) throws Exception;

    @Modifying
    @Query(value = "delete from RuleGroupEntity where ruleGroupId=?1")
    public Integer deleteRuleGroupById(Integer ruleGroupId) throws Exception;

    @Query(value = "select new com.hualude.roadsign.dto.RuleGroupDto(ruleGroupId,ruleGroupName) from RuleGroupEntity ")
    public List<RuleGroupDto> getRuleGroupIdAndName() throws Exception;
}
